﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Cloud.Model;
using Cloud.BLL;
using System.Configuration;


public partial class Three_Managerment_P0401_List_blz_zhuanban : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            if (!IsPostBack)
            {
                bind("1");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    protected void AspNetPager_PageChanged(object sender, EventArgs e)
    {
        try
        {

            if (Session["users"] == null)
            {
                Response.Write("<script>alert('登录超时'); window.parent.location.href='/index.html'</script>");
            }
            bind(AspNetPager1.CurrentPageIndex.ToString());
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }
    public void bind(String pag)
    {
        try
        {
            string strsjzt = "";
            string strsjid = "";
            string strgs = "";
            string strsqly = "";
            string strbegtime = "";
            string strtimeend = "";
            string strtitle = "";
            string strtel = "";
            string strgnum = "";   //工号
            string strgtext = "";
            string strcoruu = "  ";//当前执行部门  一级
            string strhandle = "  and (handle_type = 1 or handle_type = 0 ) "; //查询事件状态   
            string strbmtype = " and bm1_type != 9";
            #region MyRegion

            //#region MyRegion


            //if (title.Value.Equals(""))
            //{

            //}
            //else
            //{
            //    strtitle = " and title like '%'+'" + title.Value + "'+'%' ";
            //}


            //if (tel.Value.Equals(""))
            //{

            //}
            //else
            //{
            //    strtel = " and appeal_tel = '" + tel.Value + "' ";
            //}

            //if (gtext.Value.Equals(""))
            //{

            //}
            //else
            //{
            //    strgtext = " and context '%'+'" + gtext.Value + "'+'%' ";
            //}
            //#endregion
            //#region 诉求来源 1
            //if (sqly_drop.SelectedItem.Value.Equals("0"))
            //{

            //}
            //else
            //{
            //    strsqly = " and source_id =" + sqly_drop.SelectedItem.Value + " ";
            //}
            //#endregion
            //#region 归属 1
            //if (gs_drop.SelectedItem.Value.Equals("0"))
            //{

            //}
            //else
            //{

            //    strgs = " and ascription_id =" + gs_drop.SelectedItem.Value + " ";
            //}
            //#endregion
            //#region 事件id  1


            //if (sjid_input.Value.Equals(""))
            //{

            //}
            //else
            //{
            //    strsjid = " and appealid  like '%'+'" + sjid_input.Value + "'+'%' ";
            //}
            //#endregion
            //#region 事件状态下拉  1

            //if (sjzt_drop.SelectedItem.Value.Equals("0"))
            //{

            //}
            //else if (sjzt_drop.SelectedItem.Value.Equals("1"))
            //{
            //    strsjzt = " and handle_type = 0 ";
            //}
            //else if (sjzt_drop.SelectedItem.Value.Equals("2"))
            //{
            //    strsjzt = " and handle_type = 2 ";
            //}
            //else if (sjzt_drop.SelectedItem.Value.Equals("3"))
            //{
            //    strsjzt = " and handle_type = 3 ";
            //}
            //else if (sjzt_drop.SelectedItem.Value.Equals("4"))
            //{
            //    strsjzt = " and handle_type = 4 ";
            //}

            //#endregion
            //#region 时间
            //if (!this.timebeg.Value.Equals("") && !this.timeend.Value.Equals(""))
            //{
            //    if (Convert.ToDateTime(this.timeend.Value) < Convert.ToDateTime(this.timebeg.Value))
            //    {
            //        Response.Write("<script>alert('时间选择错误')</script>");
            //    }
            //}
            //if (!this.timebeg.Value.Equals(""))
            //{
            //    strbegtime = " and regtime > '" + this.timebeg.Value + "' ";
            //}

            //if (!this.timeend.Value.Equals(""))
            //{
            //    strtimeend = " and regtime < '" + this.timeend.Value + "' ";
            //}
            //#endregion

            #endregion

            #region 工号
            if (((USER_INFO)Session["users"]).USER_ID.Equals("u1"))
            {
                strgnum = " and jobnum = 0";
            }
            else
            {
                strgnum = " and jobnum =" + ((USER_INFO)Session["users"]).USER_ID + " ";
            }
            #endregion




            String sql1gd = "select top 10 * from problem_zhuanban where id not in (select top (10 * (";
            String sql2page = pag;
            String sql3gd = "-1))   ";
            String sql4tj = strsjid + strsjzt + strgs + strsqly + strbegtime + strtimeend + strtitle + strtel + strgnum + strbmtype + strcoruu + strhandle + strgtext;
            String sql5gd = " id from problem_zhuanban where 1=1 " + sql4tj + " order by xbtime ) ";
            String sql6tj = strsjid + strsjzt + strgs + strsqly + strbegtime + strtimeend + strtitle + strtel + strgnum + strbmtype + strcoruu + strhandle + strgtext;
            String sql7gd = "  order by xbtime ";
            String sqls = sql1gd + sql2page + sql3gd + sql5gd + sql6tj + sql7gd;
            AspNetPager1.PageSize = 10;//设置分页大小 
            AspNetPager1.RecordCount = Convert.ToInt32(Problem_zhuanbanManager.Count_ALL(sql4tj));//设置总数据条数  
            repeater.DataSource = Problem_zhuanbanManager.Count_ALL_page(sqls);
            repeater.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rep = e.Item.FindControl("rep1") as Repeater;//找到里层的repeater对象
                Problem_zhuanban rowv = (Problem_zhuanban)e.Item.DataItem;//找到分类Repeater关联的数据项 
                int typeid = Convert.ToInt32(rowv.Source_id); //获取填充子类的id 
                IList<Sources> sou = new List<Sources>();
                sou.Add(SourcesManager.FindById(typeid));
                rep.DataSource = sou;
                rep.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return;
        }
    }

    //事件状态
    public string sjzt(int i)
    {
        try
        {

            String zts = "";
            if (i == 0)
            {
                zts = "待办理";
            }
            else if (i == 1)
            {
                zts = "已查看";
            }
            else if (i == 2)
            {
                zts = "已办理";
            }
            else if (i == 3)
            {
                zts = "已办结";
            }
            else if (i == 4)
            {
                zts = "直办";
            }
            return zts;
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('登陆信息失效,请重新登陆!'); window.parent.location.href='/index.html'</script>");
            return "";
        }

    }
}